-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Making Enum conform to Equatable
and CaseIterable
#124
Conversation
Thanks @mackoj. Could you run the tests so that the fixtures get updated, and commit them. That's why the tests are failing. |
Ok, I will do it today. |
It actually breaks Swift 4.1 support because CaseIterable has been added in Swift 4.2 |
@@ -1,14 +1,8 @@ | |||
{% if description %} | |||
/** {{ description }} */ | |||
{% endif %} | |||
public enum {{ enumName }}: {{ type }}, Codable { | |||
public enum {{ enumName }}: {{ type }}, Codable, Equatable, CaseIterable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can conditionally use the template for swift 4.2 Vs 4.1
#if swift(>=4.2)
// swift 4.2 goes here
#else
// swift 4.1 goes here
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea I will do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done it but I still have to fix the fixture...
Remove old `cases` implementation and replacing it with `CaseIterable`
Perhaps a cleaner way would be to just define a custom #if swift(<4.2)
public protocol CaseIterable {
static let allCases: [Self] { get }
}
#endif |
In the interest of time I've just opened another PR here #133. I opted to simply drop Swift 4.1 support |
Remove old
cases
implementation and replacing it withCaseIterable